package com.echo.im.engin.netty.handler.endecode;

import com.alibaba.fastjson2.JSONObject;
import com.echo.im.common.model.info.IMSendInfo;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

import java.util.List;

/**
 *
 * @author echo
 * @date 2024-08-18
 */
public class MessageProtocolDecoder extends MessageToMessageDecoder<TextWebSocketFrame> {

    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame, List<Object> list) throws Exception {

        IMSendInfo sendInfo=JSONObject.parseObject(textWebSocketFrame.text(),IMSendInfo.class);

        list.add(sendInfo);
    }

}
